-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sessionctx: record if a query hits plan cache in slow log #17088
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also update the slow_query
table.
@@ -350,10 +350,6 @@ func (e *Execute) getPhysicalPlan(ctx context.Context, sctx sessionctx.Context, | |||
e.Plan = p | |||
_, isTableDual := p.(*PhysicalTableDual) | |||
if !isTableDual && prepared.UseCache { | |||
err = e.setFoundInPlanCache(sctx, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should have been removed by https://github.com/pingcap/tidb/pull/16594/files, wonder why it appears again. 🤦
@@ -843,6 +843,7 @@ func (a *ExecStmt) LogSlowQuery(txnTS uint64, succ bool, hasMoreResults bool) { | |||
PlanDigest: planDigest, | |||
Prepared: a.isPreparedStmt, | |||
HasMoreResults: hasMoreResults, | |||
PlanFromCache: sessVars.FoundInPlanCache, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FoundInPlanCache
indicates "if the current executing statement is from plan cache", while PrevFoundInPlanCache
indicates "if the last executing statement is from plan cache". Currently, when we execute select last_plan_from_cache
, the value of PrevFoundInPlanCache
is shown as result. So I wonder which value is needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LogSlowQuery
is called before finishing execution of current query, so we should use FoundInPlanCache
I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #17088 +/- ##
===========================================
Coverage 80.1299% 80.1299%
===========================================
Files 510 510
Lines 140226 140226
===========================================
Hits 112363 112363
Misses 18868 18868
Partials 8995 8995 |
Your auto merge job has been accepted, waiting for:
|
/run-all-tests |
cherry pick to release-4.0 in PR #17121 |
What problem does this PR solve?
Issue Number: close #16197
Problem Summary:
Not a problem, this is an enhancement for diagnose purpose.
What is changed and how it works?
What's Changed:
Add new
Plan_from_cache
field in slow log.Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Side effects
N/A
Release note